<template>
  <div class="home">
    <van-nav-bar
      title="易车"
      left-text="返回"
      left-arrow
    />

    <div v-for="(v,i) in list" :key='i' class="listWrap">
      <dl @click="toDetail(v)">
        <dt><img :src="v.img[0]" alt=""></dt>
        <dd>
          <h3>{{v.title}}</h3>
          <p>{{v.date}}</p>
          <p>{{v.desc}}</p>
          <p><span style="color:red">￥{{v.price}}万</span></p>
        </dd>
      </dl>

    </div>
    <van-tabbar v-model="active">
      <van-tabbar-item icon="home-o">首页</van-tabbar-item>
      <van-tabbar-item icon="search">买车</van-tabbar-item>
      <van-tabbar-item icon="friends-o">卖车</van-tabbar-item>
      <van-tabbar-item icon="setting-o">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
// import {State,Action,Mutation} from "vuex-class"
import {getList} from "../api/index"

@Component
export default class Home extends Vue {
  private active:any=0
  private list:any[]=[]
  async getAndSet(){
    const resp=await getList()
    this.list=resp.data.data
  }
  created(){
    this.getAndSet()
  }
  toDetail(v){
    this.$router.push({path:'/detail',query:v})
  }
}
</script>

<style lang="scss" scoped>
  .listWrap{
    width: 100%;
    dl{
      width: 100%;
      height: 100px;
      display: flex;
      justify-content: start;
      align-content: center;
      padding: 0 15px;
      dt{
        width: 120px;
        img{
          width: 100px;
          border-radius: 10px;
        }
      }
      dd{
        flex: 1;
      }
    }
  }
</style>
